<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <!-- 引入bootstarp -->
    <script type="text/javascript" src="../js/bootstrap3/js/bootstrap.js"></script>
    <link rel="stylesheet" href="../js/bootstrap3/css/bootstrap.css">
    <!-- 引入bootstrap table的css、js -->
    <link type="text/css" rel="stylesheet" href="../js/bootstrap-table/bootstrap-table.css">
    <script type="text/javascript" src="../js/bootstrap-table/bootstrap-table.js"></script>
    <script type="text/javascript" src="../js/bootstrap-table/locale/bootstrap-table-zh-CN.js"></script>
    <!-- 引入bootstrap datetime的css、js -->
    <link type="text/css" rel="stylesheet" href="../js/bootstrap-datetimepicker/css/bootstrap-datetimepicker.css">
    <script type="text/javascript" src="../js/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js"></script>
    <script type="text/javascript" src="../js/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
</head>
<body>
<form class="form-inline">
    <div class="form-group">
        <label for="username">
            <font color="red">店铺名称</font>
        </label>
        <input type="text" class="form-control" id="storeName" placeholder="请输入用户名">
        <label for="startTime">
            <font color="red">时间</font>
        </label>
        <input type="text" class="date form-control" id="startTime" placeholder="请输入开始时间">
        <i class="glyphicon glyphicon-calendar"></i>
        <input type="text" class="date form-control" id="endTime" placeholder="请输入结束时间">
    </div>
    <button type="button" class="btn btn-primary glyphicon glyphicon-search" onclick="searchUser()">搜索</button>
    <!--<button type="button" class="btn btn-danger glyphicon glyphicon-remove" onclick="delUser()">删除店铺</button>-->

</form>
<table class="table" id="userShopTable"></table>
</body>
<script>
    $(function () {
        tables();

    })
    /**
     * 初始化页面加载所有用户店铺信息
     */
    function tables(){

        $("#userShopTable").bootstrapTable({
            url:'../zsl/findShopUserList',
            type:'post',
            pagination:true, //开启分页
            //pageList:[1, 5, 10, 15,50],//分页组件
            pageNumber:1,
            pageSize:10,//默认每页条数
            sidePagination:'server',//分页方式：client客户端分页，server服务端分页
            striped:true,//条纹表格
            clickToSelect: true,
            queryParams:function(){
                return {
                    page:this.pageNumber,
                    rows:this.pageSize,
                    storeName:$("#storeName").val(),
                    startTime:$("#startTime").val(),
                    endTime:$("#endTime").val()
                };
            },
            columns:[
                {checkbox:true},
                {field:'id',title:'用户id',width:80},
                {field:'userName',title:'用户昵称',width:80},
                {field:'userImg',title:'用户头像',width:80,formatter:function(value,row,index){
                        return "<img src='"+value+"' width='50px' height='50px'/>";
                    }},
                /*{field:'userBalance',title:'用户余额',width:80},*/
                {field:'storeName',title:'店铺名称',width:80},
                {field:'storeCreateTime',title:'店铺注册时间',width:80},
                {field:'userDate',title:'用户注册时间',width:80},
                {field:'userPhone',title:'用户手机号',width:80},
                {field:'storeType',title:'商家状态',width:80,formatter:function (value,row,index) {
                        if (value == 1){
                            return "<font color='green'>申请中</font>"
                        }if (value == 2){
                            return "<font color='blue'>申请失败</font>"
                        }if (value == 3){
                            return "<font color='red'>营业中</font>"
                        }if (value == 4){
                            return "<font color='red'>暂时整顿</font>"
                        }if (value == 5){
                            return "<font color='red'>冻结</font>"
                        }
                    }},
                {field:'aww',title:'操作',width:80,formatter:function(value,row,index){
                        var str='';
                        if(row.storeType==1){
                            str+= '<a href="javascript:caozuo('+row.storeId+',1)">批准</a> | ';
                            str+= '<a href="javascript:caozuo('+row.storeId+',2)">不批准</a> | ';
                        }
                        str += '<a href="javascript:caozuo('+row.storeId+',3)">冻结</a>';
                        return str;
                    }}
            ],
        })
    }
    /*
        调查
    * */
    function searchUser() {
        $("#userShopTable").bootstrapTable('refresh');
    }

    /**
     * 操作
     */
    function caozuo(id,falg) {
        $.post('../user/caozuo',{id:id,falg:falg},function(data){
            if(data){
                searchUser();
            }else{
                bootbox.alert({
                    message:'操作失败',
                    size:'small'
                })
            }
        })
    }

    /**
     * 时间
     */
    $('.date').datetimepicker({
        language: 'zh-CN',//显示中文
        format: 'yyyy-mm-dd hh:ii:ss',//显示格式
        minView: "month",//设置只显示到月份
        initialDate: new Date(),//初始化当前日期
        autoclose: true,//选中自动关闭
        todayBtn: true//显示今日按钮
    });
</script>
</html>